<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/include/taglib.jsp" %>
<!DOCTYPE html>
<html>
<head>
<title>添加</title>
<%@ include file="/include/header.jsp"%>
<script src="${ctx}/js/lib/jquery-ui.custom.js" type="text/javascript"></script>
<script src="${ctx}/component/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
</head>
<body>
	<div class="dialog_main">
		<div class="b_box">
			<form id="${simpleBeanName}Form">
				<input type="hidden" name="CSRFToken" value="${r"${csrfToken}"}" />
				<table class="c_table m_t10">
						<#list columnList as column>
						<tr>
							<td class="t_tit">${column.dbColumnComment}：</td>
							<td><input type="text" class="input_txt" id="${column.javaPropertyName}" name="${column.javaPropertyName}"  value="" </td>
						</tr>					
						</#list>
				</table>

			</form>
		</div>
		<div class="action_box m_t10 t_c">
			<input type="button" class="save_btn" id="addBtn" value="保存" />
		</div>
	</div>

	<script type="text/javascript">
		$(function() {
		
			$('#${simpleBeanName}Form').validator({
				fields: {
					<#list columnList as column>
			        	'#${column.javaPropertyName}': 'required;'<#if column_has_next>,</#if>
		    		</#list>
			    },
			    valid:function(){
			    	// 序列化表单参数
					var serializedForm = $("#${simpleBeanName}Form").serialize();
					$.post("${ctx}/${simpleBeanName}/add.do", serializedForm, function(result) {
						if ("succ" == result) {
							alert("操作成功");
							// 刷新父列表页面
							parent.search(); 
							// 关闭弹窗窗口
							parent.${simpleBeanName}Dialog.close();
						} else if ("notThroughSecurityCheck" == result["isThroughSecurityCheck"]) { // 如果不通过安全检查
							var mess = result["mess"];
							$.post("${ctx}/common/notThroughSecurityCheck.do?ts=" + new Date().getTime(), mess, function(res) {
								alert(res);
							}, "json");
						} else {
							alert(result);
						}
					},
					"json");
			    }
			});
			
		});

	</script>
</body>
</html>